#pragma once 

#include "Core\NervusSharedHeader.h"
#include "Render\CRenderSystem.h"

namespace Nervus {
	namespace Render {
		/*
		struct MeshVertex11 {
			FLOAT X, Y, Z;      // position
			D3DXCOLOR Color;    // color
		};
		*/


		class D3D11RenderSystem : public RenderSystem {
			friend class Core::EngineCore;
			friend class D3D11Mesh;
			friend class D3D11Sprite;

		private:

			RenderLayout* mRenderLayout;


			D3D_DRIVER_TYPE mDriverType;
			ID3D11Device* mDevice;
			ID3D11DeviceContext* mDeviceContext;
			IDXGISwapChain* mSwapChain;
			ID3D11RenderTargetView* mBackBuffer;


			ID3D11VertexShader* mBasicVShader;
			ID3D11PixelShader* mBasicPShader;

			ID3D11InputLayout* mVertexFormat;

			ID3D11DepthStencilView* mDepthStencilView;
			ID3D11Texture2D* mDepthStencilBuffer;

			ID3D11DepthStencilState* mDepthStencilState3D;
			ID3D11DepthStencilState* mDepthStencilState2D;



			ID3D11VertexShader* mBasicVShader2;



			//Camera
			struct cbPerObject
			{
				XMMATRIX  WVP;
			};
			ID3D11Buffer* cbPerObjectBuffer;
			cbPerObject cbPerObj;

			XMFLOAT4X4 WVP;
			XMFLOAT4X4 matWorld;
			XMFLOAT4X4 matView;
			XMFLOAT4X4 matProj;

			XMFLOAT4X4 matView2d;
			XMFLOAT4X4 matProj2d;


			
			XMFLOAT4 camUp;



			bool loadShaders();




			RenderLayout* getActiveRenderLayout();
		public:
			//XMFLOAT4 camPosition;
			//XMFLOAT4 camTarget;




			D3D11RenderSystem(Core::Window*);
			~D3D11RenderSystem();




			bool launchRenderSystem();

			bool toggleFullscreen();



			void beginRender(f32);
			void endRender();


			Mesh* createMesh(vector<MeshVertex>, DWORD*);
			Sprite* createSprite(D3DXVECTOR2, Texture*);





			void shaderOne();
			void shaderTwo();




			void enable3D();
			void enable2D();





		};
		
	}
}